<?php
namespace app\api\controller;
use think\Controller;
use think\Exception;

class Category extends Controller
{
    private  $obj;
    public function _initialize() {
        $this->obj = model("Category");
    }
    public function getCategoryByParentId() {
        $id = input('post.id',0, 'intval');
        if(!$id) {
            $this->error('ID不合法');
        }
        // 通过父级分类获取子分类
        $categorys = $this->obj->getNormalCategoryByParentId($id);
        if(!$categorys) {
            throw new Exception('资源未找到',404);
        }
        return $this->result($categorys,200);
    }





}
